package com.zlx.mall.basic.util.json;

/**
 * @author qingke
 **/
public class JsonSerializationException extends JsonRuntimeException {

    private static final String DEFAULT_MESSAGE = "Json util serialize failed. ";

    private static final String MESSAGE_FOR_SPECIFIED_CLASS = "Json util serialize for class [%s] failed. ";

    private Class<?> serializedClass;

    public JsonSerializationException(Class<?> serializedClass) {
        super(String.format(MESSAGE_FOR_SPECIFIED_CLASS, serializedClass.getName()));
        this.serializedClass = serializedClass;
    }

    public JsonSerializationException(Throwable throwable) {
        super(DEFAULT_MESSAGE, throwable);
    }

    public JsonSerializationException(Class<?> serializedClass, Throwable throwable) {
        super(String.format(MESSAGE_FOR_SPECIFIED_CLASS, serializedClass.getName()), throwable);
        this.serializedClass = serializedClass;
    }

    public Class<?> getSerializedClass() {
        return serializedClass;
    }
}
